import Vue from 'vue'
import App from './App'
import mta from './static/js/mta_analysis.js';
// import tabBar from "./components/tabBar/tabBar";
import uniBadge from "./components/uni-badge/uni-badge.vue";
import uniPopup from "./components/uni-popup/uni-popup.vue";
import yuKeFu from "./components/yu-kefu/yu-kefu.vue"
import request from "./static/js/request.js";
// #ifdef H5
import wx from 'jweixin-module';
// #endif
//引入vuex
import store from './store'
//把vuex定义成全局组件
Vue.prototype.$store = store
Vue.config.productionTip = false
Vue.prototype.$imgUrl="https://weizong.file.cxbyi.com/images/";
Vue.prototype.$mta=mta;
Vue.prototype.$money=function(val){
      var str = (val/100).toFixed(2) + '';
      var intSum = str.substring(0,str.indexOf("."));//取到整数部分
      var dot = str.substring(str.length,str.indexOf("."));//取到小数部分搜索
      var ret = intSum + dot;
      return ret;
 }
Vue.prototype.$digitUppercase = function(n) {
    var fraction = ['角', '分'];
    var digit = [
        '零', '壹', '贰', '叁', '肆',
        '伍', '陆', '柒', '捌', '玖'
    ];
    var unit = [
        ['元', '万', '亿'],
        ['', '拾', '佰', '仟']
    ];
    var head = n < 0 ? '欠' : '';
    n = Math.abs(n);
    var s = '';
    for (var i = 0; i < fraction.length; i++) {
        s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
    }
    s = s || '整';
    n = Math.floor(n);
    for (var i = 0; i < unit[0].length && n > 0; i++) {
        var p = '';
        for (var j = 0; j < unit[1].length && n > 0; j++) {
            p = digit[n % 10] + unit[1][j] + p;
            n = Math.floor(n / 10);
        }
        s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
    }
    return head + s.replace(/(零.)*零元/, '元')
        .replace(/(零.)+/g, '零')
        .replace(/^整$/, '零元整');
};
 Vue.prototype.$back = () => {
	 const len = getCurrentPages().length;
	 if (len == 1) {
	 		 uni.switchTab({
	 			url: '/pages/index/index'
	 		 })
	 		
	 }else{
	 		uni.navigateBack({
	 				delta: 1
	 		}) 
	 }
	 
 }
 Vue.prototype.$http_img=function(url){
 	if(url.indexOf('http://') != 0 && url.indexOf('https://') != 0){
 		return "https://weizong.file.cxbyi.com/images/"+url;
 	}else{
 		return url;
 	}
 }  
 Vue.prototype.$http_url=function(url){
 	if(url.indexOf('http://') != 0 && url.indexOf('https://') != 0){
 		return "http://"+url;
 	}else{
 		return url;
 	}
 }  
  Vue.prototype.$oss_img=function(url){
  	if(url.indexOf('http://') != 0 && url.indexOf('https://') != 0){
  		return "https://video.cxbyi.com/"+url;
  	}else{
  		return url;
  	}
  } 
 Vue.prototype.queryParam = function(name) {
   var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
   var r = window.location.search.substr(1).match(reg);
   if (r != null) {
     return decodeURIComponent(r[2]);
   } else {
     return null;
   }
 }
 Vue.prototype.$queryUrl=function(name){
	var _search = this.url.split('?')[1];
	var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)");
	    var r=_search.match(reg);
	    if(r!=null) {
	    	return decodeURIComponent(r[2]); 
	    } else {
	    	return null;
	    }			
}
App.mpType = 'app'
Vue.prototype.$request=request;
Vue.prototype.wx=wx;
// #ifdef H5
Vue.prototype.wx=wx;
// #endif
// Vue.component('tabBar',tabBar)
Vue.component('uniBadge',uniBadge)
Vue.component('uniPopup',uniPopup)
Vue.component('yuKeFu',yuKeFu)


const app = new Vue({
    ...App,
	store
});
app.$mount();
